﻿using System.Collections.Generic;
using CodeGenerator.interfaces;

namespace CodeGenerator.Implementations
{
    class Constructor : MultipleTargetObject, IConstructor
    {

        private readonly IList<IDatabaseColumn> _columns;
        private string _SignatureHash = "";
        private string _tableName;
        public Constructor(string TableName, IList<IDatabaseColumn> Columns)
        {
            _tableName = TableName;
            _columns = Columns;
            CreateSignature();
        }

        public IList<IDatabaseColumn> Columns
        {
            get { return _columns; }
        }

        public string DalLoaderName
        {
            get
            {
                string res = "";
                foreach (IDatabaseColumn databaseColumn in _columns)
                {
                    res += Common.Formatting.ToString_OneTwoThree(databaseColumn.ColumnName);
                }
                return res;
            }
        }
        public string TableName
        {
            get { return _tableName; }
        }

        private void CreateSignature()
        {
            foreach (IDatabaseColumn c in _columns)
            {
                _SignatureHash += c.DataType.Name;
            }

        }


        public string GetSignatureHash
        {
            get { return _SignatureHash; }
        }
    }
}